<?php
defined('JOC') or die;
/**
 * Description of debug
 *
 * @author jcamelis
 */
class debug 
{

  /* 
   * @static function pr($var,$alias='')
   * $var : var to print
   * $alias : alis name alows to write severals debug::pr but only print the request one
     * DEBUG_LEVEL = 1 : equal level 2 but between html comment block <!---->
     * DEBUG_LEVEL = 2 : if R::get('alias') == alias 
     * DEBUG_LEVEL = 3 : always prints debug
     * 
  */

  static function pr($var,$alias='',$die = false )
  {
    if( defined('DEBUG_LEVEL') )
    {
      if( DEBUG_LEVEL == 3 || ( R::get('alias') == $alias && DEBUG_LEVEL != 3 ) )
      {
        echo DEBUG_LEVEL == 1 ? "<!-- \n" : '<pre>';
        if(is_array($var))
        {
          print_r($var);
        }
        else if(is_numeric($var) || is_string($var))
        {
          echo $var ;
        }
        else
        {
          var_dump($var);
        }
        echo DEBUG_LEVEL == 1 ? '-->' : '</pre>';

        if($die) die() ;
      }
    }
  }
  static function log($class = '')
  {
    if($class)
    {
      global $session ;
      if(!isset($session[$class]))
      {
        $session[$class] = Array('queries' => 0 , 'log' => '') ;
      }
    }
  }
}

